import 'package:flutter/material.dart';

class NoDataView extends StatelessWidget {
  final String message;
  final IconData icon;
  final VoidCallback? onAdd;

  const NoDataView({
    Key? key,
    required this.message,
    this.icon = Icons.sentiment_dissatisfied,
    this.onAdd,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Icon(icon, size: 64, color: Colors.grey),
          const SizedBox(height: 16),
          Text(
            message,
            style: Theme.of(
              context,
            ).textTheme.titleMedium?.copyWith(color: Colors.grey),
            textAlign: TextAlign.center,
          ),
          if (onAdd != null) ...[
            const SizedBox(height: 16),
            ElevatedButton.icon(
              icon: const Icon(Icons.add),
              label: const Text('添加'),
              onPressed: onAdd,
            ),
          ],
        ],
      ),
    );
  }
}
